<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib prefix="f" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path=request.getContextPath();
%>    

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

	<link href="/resources/css/bootstrap-4.3.1/css/bootstrap.css" rel="stylesheet">
	<script type="text/javascript" src="/resources/js/jquery-3.2.1/jquery.js"></script>
	<script type="text/javascript" src="/resources/js/jqueryvalidate/jquery.validate.js"></script>
	<script type="text/javascript" src="/resources/js/jqueryvalidate/localization/messages_zh.js"></script>
	<script type="text/javascript" src="/resources/css/bootstrap-4.3.1/js/bootstrap.js"></script>

</head>
<body>
	<h2>中央电视台春季面试成绩表</h2>
	<p>	快速过滤：
		<a href = "listApplicant?flag=0">全部</a>
		<a href = "listApplicant?flag=1">主持90分以上者</a>
		<a href = "listApplicant?flag=2">平均分80分以上者</a>
		<a href = "listApplicant?flag=3">研究生以上学历者</a>
	</p>
	<a href="toAddApplicant"><button type="button" class="btn btn-primary">添加面试者</button></a>
	<table class = "table">
		<tr>
			<td>应聘人</td>
			<td>性别</td>
			<td>年龄</td>
			<td>毕业学校</td>
			<td>所学专业</td>
			<td>学历</td>
			<td>学位</td>
			<td>面试成绩</td>
			<td>平均分</td>
			<td>操作</td>
		</tr>
		<c:forEach items="${applicantPage.list }" var = "applicant">
			<tr>
			<!-- new Applicant(id, name, gender, birthday, major, edu, degree, created) -->
				<td>${applicant.name }</td>
				<td>${applicant.gender }</td>
				<td>${applicant.birthday }</td>
				<td>${applicant.college }</td>
				<td>${applicant.major }</td>
				<td>
					<c:choose>
						<c:when test="${applicant.edu==1 }">大专</c:when>
						<c:when test="${applicant.edu==2 }">本科</c:when>
						<c:when test="${applicant.edu==3 }">研究生</c:when>
						<c:otherwise>其他</c:otherwise>
					</c:choose>
				
				
				</td>
				<td>
				
					<c:choose>
						<c:when test="${applicant.degree==1 }">学士</c:when>
						<c:when test="${applicant.degree==2 }">硕士</c:when>
						<c:when test="${applicant.degree==3 }">博士</c:when>
						<c:otherwise>其他</c:otherwise>
					</c:choose>
				
				</td>
				<td>${applicant.strScore }</td>
				<td>${applicant.avgScore }</td>
				<td>
					<a href="toUpdateApp?id=${applicant.id }">更新</a>
					<a href="javascript:delApp(${applicant.id })">删除</a>
					<a href="toAddScore?aid=${applicant.id }">录入成绩</a>
				</td>
			</tr>
		</c:forEach>
	</table>

	<nav aria-label="Page navigation example">
	  <ul class="pagination">
	    <li class="page-item"><a class="page-link" href="listApplicant?pageNum=1">首页</a></li>
	    <c:forEach begin="${topicPage.pageNum-2>1?topicPage.pageNum-2:1}" 
		       end="${applicantPage.pageNum+2<applicantPage.pages ? applicantPage.pageNum+2:applicantPage.pages}" step="1" var="page">
		    	<c:if test="${page==applicantPage.pageNum}">
		    		<li class="page-item active" aria-current="page">
				      <a class="page-link">
				         ${page}
				        <span class="sr-only">(current)</span>
				      </a>
				    </li>
		    	</c:if>
		    	<c:if test="${page!=applicantPage.pageNum}">
    		<li class="page-item"><a class="page-link" href="listApplicant?pageNum=${page }" >${page}</a></li>
    		</c:if>    	
    		</c:forEach>
	    <li class="page-item"><a class="page-link" href="listApplicant?pageNum=${applicantPage.pages }">尾页</a></li>
	  </ul>
	</nav>
	<script type="text/javascript">
	
		function delApp(id){
			
			$.post("delApp",{id:id},function(msg){
				
				if(msg > 0 ){
					
					alert("删除成功！");
					location = "listApplicant";
					
				}else{
					alert("删除失败！");
				}
				
			})
			
			
			
		}
	
	
	
	</script>
	
	
</body>
</html>